﻿Option Strict On
Option Explicit On

Namespace Blog

    <CLSCompliant(True)> _
    Public Class PostUtils

#Region "Constants"



#End Region

#Region "Methods"

        ''' <summary>
        ''' Return Post by Post Id
        ''' </summary>
        ''' <param name="intPostId">PostId - Integer</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Shared Function GetPostsByPostId(ByVal intPostId As Integer) As BlogSpark.Blog.Post

            Dim objPost As BlogSpark.Blog.Post
            Dim dt As DataTable = BlogSpark.DataProvider.SPs.GetPostsByPostId(BlogSpark.DataProvider.Data.ConnectionType, intPostId).Tables(0)

            If dt.Rows.Count > 0 Then
                objPost = New BlogSpark.Blog.Post
                objPost.Fill(dt.Rows(0))

                Return objPost
            Else
                Return Nothing
            End If

        End Function

        Public Shared Function GetPostByUrl(ByVal intBlogId As Integer, ByVal strUrl As String) As BlogSpark.Blog.Post

            Dim objPost As BlogSpark.Blog.Post
            Dim dt As DataTable = BlogSpark.DataProvider.SPs.GetPostsByUrl(BlogSpark.DataProvider.Data.ConnectionType, intBlogId, strUrl).Tables(0)

            If dt.Rows.Count > 0 Then
                objPost = New BlogSpark.Blog.Post
                objPost.Fill(dt.Rows(0))

                Return objPost
            Else
                Return Nothing
            End If

        End Function

#End Region

    End Class

End Namespace

